
#include<iostream>
#include<vector>

using namespace std;

vector<int>aa(2e6 + 10);

int main()
{
	int a, b;
	cin >> a>>b;
	for (int i = 1; i <= a; i++)
	{
		cin >> aa[i];
	}
	for (int i = 0; i < b; i++)
	{
		int j;
		cin >> j;
		cout << aa[j] << endl;
	}

	return 0;
}
